package com.yuqian.JavaSe.thread.cands;

public class Customer<T> {
	private Product<T> product;
	
	Customer(Product<T> product){
		this.product =product;
	}
	
	public void consumeProduct() {
		synchronized (this.product) {
			while(true) {
				if(this.product.getProducts().size()==0) {
					try {
						this.product.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}else {
					this.product.getProducts().removeLast();
					System.out.println("消费者消费一个产品");
					this.product.notifyAll();
				}
			}
		}
	}
}
